﻿@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Enums.Base
@using ZBJF.Warranty.Model
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.ServiceProject
@{
    var id = Model != null ? Model.ID : 0;
}
<ul class="nav nav-tabs">
    <li><a href="/ServiceProject/ServiceProjectIndex">服务项目列表</a></li>
    <li class="active"><a href="/ServiceProject/ServiceProjectEdit/0">添加服务项目</a></li>
</ul>
@using (Html.BeginForm("SaveServiceProject", "ServiceProject", FormMethod.Post, new { id = "inputForm", name = "inputForm", @class = "form-horizontal" }))
{
    @Html.HiddenFor(m => m.ID)
    <div class="control-group">
        <label class="control-label">服务项目类别：</label>
        <div class="controls">
            @Html.DropDownListFor(m =>m.ServiceProductType,ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(ServiceProductType)), new { validate = "{required:true,messages:{required:'请选择服务项目类别'}}" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">服务项目名称：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ProjectName, new { validate = "{required:true,messages:{required:'请输入清洗产品名称'}}", maxlength = 20 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">单价：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.Price, new { maxlength = 8, onkeyup = "onlyInputDecimal(this, 2)" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">单位说明：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.UnitInstruction, new { maxlength = 20 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">产品描述：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ProjectDescribe, new { maxlength = 50 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls">
            <label>
                @Html.CheckBox("IsAvailable", Model == null ? true : Model.IsAvailable)
                是否可用
            </label>
        </div>
    </div>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary Edit-R" type="button" value="保存" onclick="loading(this)">
        <input id="btnCancel" class="btn" type="button" value="重置" onclick="reset()">
    </div>
}

@section scripts{
    <script>
        function reset() {
            document.getElementById("inputForm").reset();
        }
        function loading(_this) {
            if ($("#inputForm").valid()) {
                _this.disabled = 'disabled';
                document.getElementById("inputForm").submit();
            }
        }
    </script>
}